/*
 * @Author: 李煌
 * @Date: 2024-09-02 14:15:11
 * @LastEditors: 李煌
 * @LastEditTime: 2023-05-06 15:08:52
 * @Description: 抄送人类型
 */
import { NodeType } from "../config";
import { BaseType, getUUID } from "../factory";
import { carbonTextHandle, carbonValidate } from "../tools";

/**
 * @description: 办理人类型
 * @param {*}
 * @return {*}
 */
export default class CarbornType extends BaseType {
  filename = "normal";
  form = "carbonForm";
  type = NodeType.内容;

  getStruct(fatherID, childNode, level) {
    return {
      nodeName: "内容",
      error: true,
      type: this.type,
      nodeId: getUUID(),
      setting: {
        carbonCopySetting: [
          {
            type: 1, // 直属上级
            level: 1, // 如果为部门负责人 选择层级
            member: [],
          },
        ], // 抄送人配置
      },
      childNode,
      fatherID,
      level,
    };
  }

  handleText(nodeConfig) {
    let text = [];
    carbonTextHandle(nodeConfig.setting.carbonCopySetting, text);
    return (text.length > 0 && text) || ["暂无配置"];
  }

  beforeSave(nodeConfig) {
    return carbonValidate(nodeConfig.setting.carbonCopySetting);
  }
}
